﻿using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ITG.Modules.HR.Components.HRP
{
    public class Department
    {        
        public static DataSet GetByLevel(int level)
        {
            string query;
            if (level == 1)
            {
                query = "SELECT Level1ID, Level1Name FROM HR_tblLevel1List";
            }
            else if (level == 2)
            {
                query = "SELECT Level1ID, Level2ID, Level2Name FROM HR_tblLevel2List";
            }
            else if (level == 3)
            {
                query = "SELECT Level1ID, Level2ID, Level3ID, Level3Name FROM HR_tblLevel3List";
            }
            else
            {
                query = "SELECT Level1ID, Level2ID, Level4ID Level4ID, Level4Name FROM HR_tblLevel4List";
            }

            Database db = DatabaseFactory.CreateDatabase("ITG.HRP");
            DbCommand dbCommand = db.GetSqlStringCommand(query);
            return db.ExecuteDataSet(dbCommand);
        }
    }
}